all: checkhg 00grace 01grace-util 05mkmodulexml 30opencore 35gui AWStats.module Amavis.module Apache2.module ApacheForward.module DNSDomain.module Domain.module FTP.module IPTables.module LIMA.module MySQL.module Networking.module PostfixCourier.module SSH.module SoftwareUpdate.module User.module WebDAV.module authd coreunreg coreval limadaemon opencli swupd templates 
	@echo '***' tada.wav

install: all
	# do stuff

checkhg:
	@if [ -z "`hg --quiet incoming`" ] ; then : ; else echo please hg pull -u ; exit 1 ; fi

clean:
	@echo '<=>' clean
	@rm -rf tree work
	@mkdir -p tree/opencore
	@chown root:root tree/opencore
	@chmod 0755 tree/opencore
	@mkdir -p tree/opencore/conf
	@chown root:root tree/opencore/conf
	@chmod 0755 tree/opencore/conf
	@mkdir -p tree/opencore/tools
	@chown root:root tree/opencore/tools
	@chmod 0755 tree/opencore/tools
	@mkdir -p tree/opencore/bin
	@chown root:root tree/opencore/bin
	@chmod 0755 tree/opencore/bin
	@mkdir -p tree/opencore/modules
	@chown root:root tree/opencore/modules
	@chmod 0755 tree/opencore/modules
	@mkdir -p tree/opencore/share
	@chown root:root tree/opencore/share
	@chmod 0755 tree/opencore/share
	@mkdir -p tree/openpanel
	@chown root:root tree/openpanel
	@chmod 0755 tree/openpanel
	@mkdir -p tree/opencore/templates
	@chown root:root tree/opencore/templates
	@chmod 0755 tree/opencore/templates
	@mkdir -p tree/opencore/log
	@chown opencore:opencore tree/opencore/log
	@chmod 0750 tree/opencore/log
	@mkdir -p tree/opencore/cache
	@chown opencore:opencore tree/opencore/cache
	@chmod 0750 tree/opencore/cache
	@mkdir -p tree/opencore/db
	@chown opencore:opencore tree/opencore/db
	@chmod 0755 tree/opencore/db
	@mkdir -p tree/opencore/log
	@chown opencore:opencore tree/opencore/log
	@chmod 0750 tree/opencore/log
	@mkdir -p tree/opencore/debug
	@chown opencore:opencore tree/opencore/debug
	@chmod 0750 tree/opencore/debug
	@mkdir -p tree/opencore/conf/staging
	@chown opencore:opencore tree/opencore/conf/staging
	@chmod 0750 tree/opencore/conf/staging
	@mkdir -p tree/opencore/conf/rollback
	@chown opencore:opencore tree/opencore/conf/rollback
	@chmod 0750 tree/opencore/conf/rollback
	@mkdir -p tree/opencore/sockets
	@chown opencore:authd tree/opencore/sockets
	@chmod 0775 tree/opencore/sockets
	@mkdir -p tree/opencore/sockets/authd
	@chown root:authd tree/opencore/sockets/authd
	@chmod 0770 tree/opencore/sockets/authd
	@mkdir -p tree/opencore/sockets/swupd
	@chown root:authd tree/opencore/sockets/swupd
	@chmod 0770 tree/opencore/sockets/swupd
	@mkdir -p tree/opencore/db/panel
	@chown root:authd tree/opencore/db/panel
	@chmod 0770 tree/opencore/db/panel

00grace:
	@echo '==>' grace
	@bin/clone grace
	@if [ -e work/grace/.wharf_rebuildme ] ; then \
		echo '-->' building and installing && \
		cd work/grace/src/libgrace && ./configure -q && make -s clean all install && cd ../../../.. && \
		cd work/grace/src/libdbfile && ./configure -q && make -s clean all install && cd ../../../.. && \
		cd work/grace/src/libquerido && ./configure -q && make -s clean all install && cd ../../../.. && \
		cd work/grace/src/libgrace-pcre && ./configure -q && make -s clean all install && cd ../../../.. && \
		cd work/grace/src/matrixssl && ./configure -q && make all && ./makeinstall && cd ../../../.. && \
		cd work/grace/src/libgrace-ssl && ./configure -q && make -s clean all install && cd ../../../.. && \
		for d in work/* ; do \
			touch $$d/.wharf_rebuildme ; \
		done && \
		rm -f work/grace/.wharf_rebuildme ; \
	fi
	@echo '<==' grace

01grace-util:
	@echo '==>' grace-util
	@bin/clone grace-util
	@if [ -e work/grace-util/.wharf_rebuildme ] ; then \
		echo '-->' building and installing && \
		cd work/grace-util && ./configure -q && make -s clean all install && cd ../../../.. \
		rm -f work/grace-util/.wharf_rebuildme ; \
	fi
	@echo '<==' grace-util

05mkmodulexml:
	@echo '==>' mkmodulexml
	@bin/clone mkmodulexml
	@if [ -e work/mkmodulexml/.wharf_rebuildme ] ; then \
		cd work/mkmodulexml && \
		echo '-->' configuring && \
		./configure -q && \
		echo '-->' building && \
		make -s clean all && \
		echo '-->' to tree && \
		cd ../.. && \
		rm -f tree/opencore/bin/mkmodulexml && \
		cp work/mkmodulexml/mkmodulexml tree/opencore/bin/ && \
		cp work/mkmodulexml/mkmodulexml /usr/local/bin/ && \
		rm -f work/mkmodulexml/.wharf_rebuildme ; \
	fi
	@echo '<==' mkmodulexml


30opencore:
	@echo '==>' opencore
	@bin/clone opencore
	@if [ -e work/opencore/.wharf_rebuildme ] ; then \
		cd work/opencore && \
		echo '-->' configuring && \
		./configure -q && \
		cd api/c++/src && ./configure -q && cd ../../.. && \
		cd api/grace/src && ./configure -q && cd ../../.. && \
		echo '-->' building && \
		make -s clean all && \
		cd api/c++/src && make -s clean all && cd ../../.. && \
		cd api/grace/src && make clean all && cd ../../.. && \
		rm -f kickstart.panel.db && make -s kickstart.panel.db && \
		echo '-->' to tree && \
		cd ../.. && \
		rm -rf tree/opencore/opencore.app/ && \
		cp -R work/opencore/opencore.app tree/opencore/bin/ && \
		ln -sf opencore.app/exec tree/opencore/bin/opencore && \
		rm -rf tree/opencore/techsupport.app/ && \
		cp -R work/opencore/techsupport.app tree/opencore/bin/ && \
		ln -sf techsupport.app/exec tree/opencore/bin/techsupport && \
		rm -rf tree/opencore/api && \
		cp -R work/opencore/api tree/opencore/ && \
		cp work/opencore/kickstart.panel.db tree/opencore/db/panel/panel.db && \
		chown opencore:authd tree/opencore/db/panel/panel.db && \
		rm -f work/opencore/.wharf_rebuildme ; \
	fi
	@echo '<==' opencore

35gui:
	@echo '==>' newgui
	@bin/clone newgui
	@if [ -e work/newgui/.wharf_rebuildme ] ; then \
		cd work/newgui && \
		echo '-->' building && \
		make  && \
		echo '-->' to tree && \
		cd ../.. && \
		rm -rf tree/openpanel && \
		cp -R work/newgui tree/openpanel && \
		rm -f work/newgui/.wharf_rebuildme ; \
	fi
	@echo '<==' newgui

AWStats.module:
	@echo '==>' AWStats.module
	@bin/clone AWStats.module
	@if [ -e work/AWStats.module/.wharf_rebuildme ] ; then \
		bin/buildmodule AWStats.module && \
		bin/installmodule AWStats.module && \
		rm -f work/AWStats.module/.wharf_rebuildme ; \
	fi
	@echo '<==' AWStats.module

Amavis.module:
	@echo '==>' Amavis.module
	@bin/clone Amavis.module
	@if [ -e work/Amavis.module/.wharf_rebuildme ] ; then \
		bin/buildmodule Amavis.module && \
		bin/installmodule Amavis.module && \
		rm -f work/Amavis.module/.wharf_rebuildme ; \
	fi
	@echo '<==' Amavis.module

Apache2.module:
	@echo '==>' Apache2.module
	@bin/clone Apache2.module
	@if [ -e work/Apache2.module/.wharf_rebuildme ] ; then \
		bin/buildmodule Apache2.module && \
		bin/installmodule Apache2.module && \
		rm -f work/Apache2.module/.wharf_rebuildme ; \
	fi
	@echo '<==' Apache2.module

ApacheForward.module:
	@echo '==>' ApacheForward.module
	@bin/clone ApacheForward.module
	@if [ -e work/ApacheForward.module/.wharf_rebuildme ] ; then \
		bin/buildmodule ApacheForward.module && \
		bin/installmodule ApacheForward.module && \
		rm -f work/ApacheForward.module/.wharf_rebuildme ; \
	fi
	@echo '<==' ApacheForward.module

DNSDomain.module:
	@echo '==>' DNSDomain.module
	@bin/clone DNSDomain.module
	@if [ -e work/DNSDomain.module/.wharf_rebuildme ] ; then \
		bin/buildmodule DNSDomain.module && \
		bin/installmodule DNSDomain.module && \
		rm -f work/DNSDomain.module/.wharf_rebuildme ; \
	fi
	@echo '<==' DNSDomain.module

Domain.module:
	@echo '==>' Domain.module
	@bin/clone Domain.module
	@if [ -e work/Domain.module/.wharf_rebuildme ] ; then \
		echo '-->' to tree && \
		bin/installmodule Domain.module && \
		rm -f work/Domain.module/.wharf_rebuildme ; \
	fi
	@echo '<==' Domain.module

FTP.module:
	@echo '==>' FTP.module
	@bin/clone FTP.module
	@if [ -e work/FTP.module/.wharf_rebuildme ] ; then \
		bin/buildmodule FTP.module && \
		bin/installmodule FTP.module && \
		rm -f work/FTP.module/.wharf_rebuildme ; \
	fi
	@echo '<==' FTP.module

IPTables.module:
	@echo '==>' IPTables.module
	@bin/clone IPTables.module
	@if [ -e work/IPTables.module/.wharf_rebuildme ] ; then \
		cd work/IPTables.module && \
		echo '-->' configuring && \
		./configure -q && \
		echo '-->' building && \
		make -s clean all && \
		echo '-->' to tree && \
		cd ../.. && \
		bin/installmodule IPTables.module && \
		rm -f work/IPTables.module/.wharf_rebuildme ; \
	fi
	@echo '<==' IPTables.module

LIMA.module:
	@echo '==>' LIMA.module
	@bin/clone LIMA.module
	@if [ -e work/LIMA.module/.wharf_rebuildme ] ; then \
		bin/buildmodule LIMA.module && \
		bin/installmodule LIMA.module && \
		rm -f work/LIMA.module/.wharf_rebuildme ; \
	fi
	@echo '<==' LIMA.module

MySQL.module:
	@echo '==>' MySQL.module
	@bin/clone MySQL.module
	@if [ -e work/MySQL.module/.wharf_rebuildme ] ; then \
		bin/buildmodule MySQL.module && \
		bin/installmodule MySQL.module && \
		rm -f work/MySQL.module/.wharf_rebuildme ; \
	fi
	@echo '<==' MySQL.module

Networking.module:
	@echo '==>' Networking.module
	@bin/clone Networking.module
	@if [ -e work/Networking.module/.wharf_rebuildme ] ; then \
		bin/buildmodule Networking.module && \
		bin/installmodule Networking.module && \
		rm -f work/Networking.module/.wharf_rebuildme ; \
	fi
	@echo '<==' Networking.module

PostfixCourier.module:
	@echo '==>' PostfixCourier.module
	@bin/clone PostfixCourier.module
	@if [ -e work/PostfixCourier.module/.wharf_rebuildme ] ; then \
		bin/buildmodule PostfixCourier.module && \
		bin/installmodule PostfixCourier.module && \
		rm -f work/PostfixCourier.module/.wharf_rebuildme ; \
	fi
	@echo '<==' PostfixCourier.module

SSH.module:
	@echo '==>' SSH.module
	@bin/clone SSH.module
	@if [ -e work/SSH.module/.wharf_rebuildme ] ; then \
		bin/installmodule SSH.module && \
		rm -f work/SSH.module/.wharf_rebuildme ; \
	fi
	@echo '<==' SSH.module

SoftwareUpdate.module:
	@echo '==>' SoftwareUpdate.module
	@bin/clone SoftwareUpdate.module
	@if [ -e work/SoftwareUpdate.module/.wharf_rebuildme ] ; then \
		bin/buildmodule SoftwareUpdate.module && \
		bin/installmodule SoftwareUpdate.module && \
		rm -f work/SoftwareUpdate.module/.wharf_rebuildme ; \
	fi
	@echo '<==' SoftwareUpdate.module

User.module:
	@echo '==>' User.module
	@bin/clone User.module
	@if [ -e work/User.module/.wharf_rebuildme ] ; then \
		bin/buildmodule User.module && \
		bin/installmodule User.module && \
		rm -f work/User.module/.wharf_rebuildme ; \
	fi
	@echo '<==' User.module

WebDAV.module:
	@echo '==>' WebDAV.module
	@bin/clone WebDAV.module
	@if [ -e work/WebDAV.module/.wharf_rebuildme ] ; then \
		bin/buildmodule WebDAV.module && \
		bin/installmodule WebDAV.module && \
		rm -f work/WebDAV.module/.wharf_rebuildme ; \
	fi
	@echo '<==' WebDAV.module

authd:
	@echo '==>' authd
	@bin/clone authd
	@if [ -e work/authd/.wharf_rebuildme ] ; then \
		cd work/authd && \
		echo '-->' configuring && \
		./configure -q && \
		echo '-->' building && \
		make -s clean all && \
		make -s -C fcat clean all && \
		make -s -C runas clean all && \
		echo '-->' to tree && \
		cd ../.. && \
		rm -rf tree/authd/authd.app/ && \
		cp -R work/authd/authd.app tree/opencore/bin/ && \
		ln -sf authd.app/exec tree/opencore/bin/authd && \
		cp work/authd/opencore-tools/* tree/opencore/tools/ && \
		cp work/authd/fcat/fcat tree/opencore/tools/ && \
		cp work/authd/runas/runas tree/opencore/tools/ && \
		rm -f work/authd/.wharf_rebuildme ; \
	fi
	@echo '<==' authd

coreunreg:
	@echo '==>' coreunreg
	@bin/clone coreunreg
	@if [ -e work/coreunreg/.wharf_rebuildme ] ; then \
		cd work/coreunreg && \
		echo '-->' configuring && \
		./configure -q && \
		echo '-->' building && \
		make -s clean all && \
		echo '-->' to tree && \
		cd ../.. && \
		rm -f tree/opencore/bin/coreunreg && \
		cp work/coreunreg/coreunreg tree/opencore/bin/ && \
		rm -f work/coreunreg/.wharf_rebuildme ; \
	fi
	@echo '<==' coreunreg


coreval:
	@echo '==>' coreval
	@bin/clone coreval
	@if [ -e work/coreval/.wharf_rebuildme ] ; then \
		cd work/coreval && \
		echo '-->' configuring && \
		./configure -q && \
		echo '-->' building && \
		make -s clean all && \
		echo '-->' to tree && \
		cd ../.. && \
		rm -f tree/opencore/bin/coreval && \
		cp work/coreval/coreval tree/opencore/bin/ && \
		rm -f work/coreval/.wharf_rebuildme ; \
	fi
	@echo '<==' coreval


limadaemon:
	@echo '==>' limadaemon
	@bin/clone limadaemon
	@if [ -e work/limadaemon/.wharf_rebuildme ] ; then \
		echo '-->' building and installing && \
		cd work/limadaemon && ./configure -q && make -s clean all && cd ../../ && \
		cd work/limadaemon/limasubmit  && ./configure -q && make -s clean all && cd ../../.. && \
		cd work/limadaemon && make -s install && cd ../.. && \
		rm -f work/limadaemon/.wharf_rebuildme ; \
	fi
	@echo '<==' limadaemon

opencli:
	@echo '==>' opencli
	@bin/clone opencli
	@if [ -e work/opencli/.wharf_rebuildme ] ; then \
		cd work/opencli && \
		echo '-->' configuring && \
		./configure -q && \
		echo '-->' building && \
		make -s clean all && \
		echo '-->' to tree && \
		cd ../.. && \
		rm -f tree/opencore/bin/opencli && \
		cp work/opencli/opencli tree/opencore/bin/ && \
		rm -f work/opencli/.wharf_rebuildme ; \
	fi
	@echo '<==' opencli

swupd:
	@echo '==>' swupd
	@bin/clone swupd
	@if [ -e work/swupd/.wharf_rebuildme ] ; then \
		cd work/swupd && \
		echo '-->' configuring && \
		./configure -q && \
		echo '-->' building && \
		make -s clean all && \
		echo '-->' to tree && \
		cd ../.. && \
		rm -rf tree/opencore/bin/swupd.app && \
		cp -R work/swupd/swupd.app tree/opencore/bin/ && \
		ln -sf swupd.app/exec tree/opencore/bin/swupd && \
		rm -f work/swupd/.wharf_rebuildme ; \
	fi
	@echo '<==' swupd

templates:
	@echo '<=>' included templates
	@mkdir -p tree/opencore/templates || echo
	@cp -f work/*.module/templates/*.xml tree/opencore/templates/ || echo

